package com.qf.medicaldoctoradmin.healthMonitor.drugRemind.controller;

import com.qf.common.common.R;
import com.qf.common.entity.DrugSchedule;
import com.qf.medicaldoctoradmin.healthMonitor.drugRemind.service.DrugScheduleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "用药提醒API")
@RestController
@CrossOrigin
@RequestMapping("/drugSchedule")
public class DrugScheduleController {
    @Resource
    private DrugScheduleService drugScheduleService;


    @ApiOperation(value = "获取所有用药提醒", notes = "获取登录用户的所有用药提醒，包含未启用和已启用的")
    @GetMapping("/getList")
    public R getList() {
        List<DrugSchedule> scheduleList = drugScheduleService.getList();
        return R.ok(scheduleList);
    }

    @ApiOperation(value = "添加用药提醒", notes = "添加登录用户的用药提醒")
    @PostMapping("/insert")
    public R insert(@RequestBody DrugSchedule drugSchedule) {
        drugScheduleService.insert(drugSchedule);
        return R.ok("操作成功");
    }

    @ApiOperation(value = "更新用药提醒", notes = "根据id更新用药提醒")
    @PostMapping("/update")
    public R update(@RequestBody DrugSchedule drugSchedule) {
        drugScheduleService.update(drugSchedule);
        return R.ok("操作成功");
    }

    @ApiOperation(value = "删除用药提醒", notes = "不要轻易删除，根据id，删除用药提醒")
    @GetMapping("/delete")
    public R delete(Integer id) {
        drugScheduleService.delete(id);
        return R.ok("操作成功");
    }

}
